import { ApiResponse, ArticleDetail } from '@/types/data'
import { RootThunkAction } from '@/types/store'
import instance from '@/utils/request'

export const getArticle = (id: string): RootThunkAction => {
  return async (dispatch) => {
    const res = await instance.get<ApiResponse<ArticleDetail>>(
      `/articles/${id}`
    )
    // console.log(res)
    dispatch({
      type: 'article/getArticleDetail',
      payload: res.data.data,
    })
  }
}
